package touro.finances.gui;

import java.awt.BorderLayout;
import java.sql.SQLException;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import touro.finances.control.ListExpensesController;
import touro.finances.model.FinancesDatabase;

public class GUI extends JFrame{

	private JPanel contentPane;
	private JTabbedPane tabs;
	private ExpensesPanel ep;
	private ListExpenses le;
	
	
	public GUI(FinancesDatabase fd) throws SQLException{
		setTitle("Finance Manager");
		setSize(600,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLocationRelativeTo(null);
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException e) {
		} catch (InstantiationException e) {
		} catch (IllegalAccessException e) {
		} catch (UnsupportedLookAndFeelException e) {
		}
		
		ep = new ExpensesPanel(fd);
		le = new ListExpenses(fd);
		
		tabs = new JTabbedPane();
		tabs.addTab("Add Expense", ep);
		//on tabChange to ListExpenses, call method that returns Vector of data
		tabs.addTab("List Expenses", le);
		tabs.addChangeListener(new ListExpensesController(fd, le));
		
		contentPane = new JPanel();
		contentPane.setLayout(new BorderLayout());
		contentPane.add(tabs);
		setContentPane(contentPane);
	}

}
